package com.attilax.core;

import java.io.File;
import java.lang.reflect.InvocationTargetException;

import org.apache.commons.lang3.reflect.MethodUtils;

import com.attilax.io.DirTraveService;
import com.attilax.ref.refServiceV2s530;

public class classLoaderUtil {

	public static void main(String[] args)
			throws ClassNotFoundException, NoSuchMethodException, IllegalAccessException, InvocationTargetException {

		ClassLoader_StandardExecutor clsldr1 = new ClassLoader_StandardExecutor();
		
		classLoaderUtil.addurl_byJarDir("C:\\0wkspc\\hislog\\libtomcart", clsldr1);
		
		classLoaderUtil.addurl_byJarDir("C:\\0wkspc\\hislog\\WebContent\\WEB-INF\\lib", clsldr1);
		clsldr1.addURL(new File("C:\\0wkspc\\hislog\\WebContent\\WEB-INF\\classes"));
		// refServiceV2s530.loadclass_urlclassloader("C:\\0wkspc\\hislog\\WebContent\\WEB-INF\\classes");

		// Class cls = Class.forName(sn.IDENTIFIER);
		Class cls = clsldr1.loadClass("com.attilax.io.pathx");
		System.out.println(clsldr1);
		System.out.println("cls.getClassLoader::" + cls.getClassLoader());
		Object r = MethodUtils.invokeStaticMethod(cls, "filemainname", "namex.jpg");

		// Object r= MethodUtils.invokeStaticMethod(cls, "isFile", "namex.jpg");
		System.out.println("--" + r);

	}

	public static void addurl_byJarDir(String jardir, final ClassLoader_StandardExecutor clsldr1) {
		new DirTraveService().traveV5_vS522(new File(jardir), new ForeachFunction() {

			@Override
			public void each(int count, File strFileName) throws Exception {
				clsldr1.addURL(strFileName);

			}
		});

	}

	public static void loadJarFromDirtrave_urlclassloader(String jardir) {

	}

}
